using PPIProxy;
using PPIDesktopClient.Entities;
using PPIDesktopClient.General;
using System;
using System.Data;
using System.Data.SqlClient;
using VMind.Global;

namespace PPIDesktopClient.Logic
{
	public static class LUtility_Polygon_Point
	{
		#region Query
        public static DataTable SelectAllByPolygon(Int32 Utility_PolygonId)
        {
            ConfigReader _Reader = ConfigReader.GetInstance();
            return WUtility_Polygon_Point.SelectAllByPolygon(Utility_PolygonId,_Reader.GetConnectionString()).Tables[0];
        }

        public static EUtility_Polygon_Point[] SelectAllByPolygon2(Int32 Utility_PolygonId)
        {
            DataRow _Datarow;
            ConfigReader _Reader = ConfigReader.GetInstance();
            DataTable _Datatable = WUtility_Polygon_Point.SelectAllByPolygon(Utility_PolygonId,_Reader.GetConnectionString()).Tables[0];
            EUtility_Polygon_Point[] _EUtility_Polygon_PointArr = new EUtility_Polygon_Point[_Datatable.Rows.Count];
            for (int i = 0; i < _Datatable.Rows.Count; i++)
            {
                _Datarow = _Datatable.Rows[i];
                _EUtility_Polygon_PointArr[i] = new EUtility_Polygon_Point(ConvertHelper.ToInt32(_Datarow["Utility_Polygon_PointId"]), new EUtility_Polygon(ConvertHelper.ToInt32(_Datarow["Utility_PolygonFK"])), ConvertHelper.Todouble(_Datarow["Latitude"]),ConvertHelper.Todouble(_Datarow["Longitude"]));
            }
            return _EUtility_Polygon_PointArr;
        }

        #region summary
		/// <summary>
		/// Date: 05/12/2008
		/// Time: 14:15:28
		/// Generated by: VMCoder
		/// Generated using VirtualGenerator
		/// </summary>
		#endregion summary
		public static DataTable SelectAll()
		{
            ConfigReader _Reader = ConfigReader.GetInstance();
			return WUtility_Polygon_Point.SelectAll(_Reader.GetConnectionString()).Tables[0];
		}
		#endregion Query

		#region CRUD
		#region summary
		/// <summary>
		/// Date: 05/12/2008
		/// Time: 14:15:28
		/// Generated by: VMCoder
		/// Generated using VirtualGenerator
		/// </summary>
		#endregion summary
        public static Int32 Insert(EUtility_Polygon_Point polygonPoint)
		{
            ConfigReader _Reader = ConfigReader.GetInstance();
			return WUtility_Polygon_Point.Insert(polygonPoint.Utility_Polygon.Utility_PolygonId, polygonPoint.Latitude, polygonPoint.Longitude,_Reader.GetConnectionString());
		}
		#region summary
		/// <summary>
		/// Date: 05/12/2008
		/// Time: 14:15:28
		/// Generated by: VMCoder
		/// Generated using VirtualGenerator
		/// </summary>
		#endregion summary
		public static void Delete(Int32 utility_Polygon_PointId)
		{
            ConfigReader _Reader = ConfigReader.GetInstance();
			WUtility_Polygon_Point.Delete(utility_Polygon_PointId,_Reader.GetConnectionString());
		}
        #region summary
        /// <summary>
        /// Date: 05/12/2008
        /// Time: 14:15:28
        /// Generated by: VMCoder
        /// Generated using VirtualGenerator
        /// </summary>
        #endregion summary
        public static void DeleteByPolygon(Int32 utility_PolygonFk)
        {
            ConfigReader _Reader = ConfigReader.GetInstance();
            WUtility_Polygon_Point.DeleteByPolygon(utility_PolygonFk,_Reader.GetConnectionString());
        }
        #endregion CRUD
	}
}

